Repository navigation
Warn and fail --check when Go vendor/ or go.mod need a resync (#343, #618) - #1357
Merged
Merged
Conversation
Two Go build breakages were reported as success. #343: in a project with a committed vendor/ (go mod vendor), wiring a socket `replace` (apply, vendor, scan --mode hosted) or removing one (rollback) leaves vendor/modules.txt out of step with go.mod, so every default build fails with "inconsistent vendoring". #618: when a patch bumps or adds a requirement in the patched module's own go.mod, the consumer's go.mod/go.sum are not updated, so the default -mod=readonly build fails with "updates to go.mod needed". In both cases apply exited 0 and apply --check said in sync. A new vendor::go_consumer_sync::audit compares the replace directives with vendor/modules.txt (go mod vendor / go work vendor layouts) and with the patched copies' go.mod requirements. apply, vendor, rollback and hosted scan now emit go_vendor_modules_txt_out_of_sync / go_requirements_out_of_sync warnings that name the go command to run. apply --check and vendor --check report them as drift until it is run. Fixes #343 Fixes #618 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
BugBot review |
Mikola Lysenko (mikolalysenko)
enabled auto-merge
October 9, 2026 17:58
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 32fb4f0. Configure here.
command_module_layering forbids rollback and scan importing apply, and envelope_helper_copies forbids a private warning_codes reader; route every caller through go_consumer_sync::audit_warnings and the test through common::envelope. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Resolve the apply.rs `--check` remedy conflict: keep the PR's rule that the "Run socket-patch apply" hint is suppressed when every drift is a Go consumer-sync drift (those name their own go command), and print main's scope-aware `check_remedy` text when the hint is shown. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Mikola Lysenko (mikolalysenko)
requested review from
Tanmay Singla (Tanmay182003) and
Wenxin Jiang (Wenxin-Jiang)
October 10, 2026 09:28
go work vendor records every use member's go.mod replaces plus the go.work replaces, but the audit compared it with the current module's go.mod only. Auditing one member reported another member's socket replace as stale (and re-running go work vendor could not clear it), and a member replace that a go.work replace of the same module overrides was reported as missing. In workspace mode the stale check now accepts a replacement from any used member or go.work, and the missing check skips entries go.work overrides. Adds parse_use_dirs to go_mod_edit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Tanmay Singla (Tanmay182003)
approved these changes
Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

LLM Description written by Claude Code:claude-opus-5-5
Fixes #343
Fixes #618
Summary
A Go
replacecan be wired correctly while the project still won't build, because two files go derives fromgo.modno longer match it. Every Go mode now warns about this with the exact command that fixes it, andapply --check/vendor --checktreat it as drift. Before, the run exited 0 with no warning and--checksaid in sync.go_vendor_modules_txt_out_of_sync(#343)vendor/whosemodules.txtdoesn't record a socketreplace, or still records one that rollback removedgo mod vendor(go work vendorfor a workspace)go_requirements_out_of_sync(#618)go.modrequires a dependency above the version the consumergo.modlists (and, at apply time, a requirement the patch added)go mod tidyRoot cause
The Go backends only edit the consumer
go.modreplace(go_mod_edit::ensure_replace_entry/drop_replace_entry). Nothing readvendor/modules.txtor the replacement'sgo.modrequirements, andverify_go_redirect_stateonly hashed the copy and checked the directive.Fix
vendor::go_consumer_sync::audit(project_root, pristine_go_mods). It is read-only and offline.vendor/modules.txt(the module's own, or thego.workroot's), parses its# M v => targetlines, and compares them with the socket-ownedreplacedirectives in both directions.go.modand compares itsrequires with the consumer's. A requirement the consumer lists at a lower version is always reported. One the consumer doesn't list is reported only when the pristinego.modshows the patch added or raised it, because upstreamgo.mods routinely require modules a pruned consumer graph never lists.applyas run warnings (JSONwarnings[]plus stderr), with the module-cachego.modpassed as the pristineapply --checkas drift; when only these drifts are present, the "Runsocket-patch apply" footer is suppressed because apply can't fix themvendoras warnings andvendor --checkas drift (per Go ledger entry)rollbackas warningsscan --mode hostedas warnings when it rewrote ago.modDesign decision: socket-patch doesn't run
go mod vendor/go mod tidyitself. Both need the go toolchain and the whole module graph (often network), and they rewrite files the user owns. That follows the v5 triage note on both issues: "synchronize … or give an actionable regeneration step". A maintainer could later make auto-running them opt-in.Known limits:
go.modisn't in the project.--check(no module cache) andvendor(no pristine) flag only the "listed lower" shape of Go apply and vendor wire in a patched module whose go.mod raises or adds a requirement without syncing the consumer go.mod/go.sum, so every defaultgo buildfails while apply, --check and VEX report success #618, which is the common security-bump case.Tests (red → green)
e2e_golang_build::committed_vendor_dir_needs_go_mod_vendor_after_apply_and_rollbackruns against real go. Flow:go mod vendor→ apply. It asserts apply emits the warning and thatgo buildreally fails with "inconsistent vendoring", then thatapply --checkexits 1 naminggo mod vendor. Aftergo mod vendor,go runprints PATCHED and check exits 0. After rollback, the stale warning appears and check exits 1. On main it fails at "apply must name the vendor/modules.txt regeneration".go buildfails while apply, --check and VEX report success #618:e2e_golang_build::patched_go_mod_requirement_bump_needs_go_mod_tidyruns against real go. The patch bumpsexample.com/depv1.0.0 → v1.1.0 in the upstreamgo.mod. It asserts the warning, that the default build fails, and that--checkexits 1 naminggo mod tidy. Aftergo mod tidy,go runprintsFIXED-PATCHEDand check exits 0. On main it fails at "apply must name the go.mod/go.sum refresh".go_consumer_sync::tests:Commands run
cargo test -p socket-patch-cli --lib --test e2e_golang_build --test e2e_vendor_golang_build --test e2e_golang_hosted_build --test e2e_golang_workspace_build --test e2e_golang_hosted_state --test e2e_golang --test spawn_env_hygiene(go 1.26.3): all greencargo test -p socket-patch-core --lib -- go_consumer_sync golang_local go_mod_edit go_sum_edit: 109 passedcargo clippy --workspace --all-features -- -D warnings: cleancargo fmt --check: the changed files are clean🤖 Generated with Claude Code
Note
Medium Risk
Changes Go apply/check/rollback/vendor behavior and CI drift semantics; logic is read-only but can cause new warnings and
--checkfailures where redirects previously looked healthy.Overview
Adds Go consumer-sync detection so socket
replacewiring is no longer treated as “done” when the project still cannot build.A new read-only
go_consumer_sync::auditcompares socket-ownedgo.modreplacedirectives against committedvendor/modules.txt(#343) and against requirements in patched local copies’go.mod(#618). It emits actionable warnings (go mod vendor/go work vendor, orgo mod tidy) with stable codesgo_vendor_modules_txt_out_of_syncandgo_requirements_out_of_sync.applyrecords pristine module-cachego.modpaths during local Go applies and surfaces warnings after a successful run;apply --checktreats these as drift and skips the generic “Runsocket-patch apply” hint when only consumer-sync issues remain. The same audit is wired intorollback,vendor/vendor --check, andscan --mode hostedwhengo.modwas rewritten. Docs inecosystems.mddocument the two failure modes; e2e tests exercise realgobuilds for vendor and requirement bumps.Reviewed by Cursor Bugbot for commit 32fb4f0. Configure here.